home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-10-25 | 24.1 KB | 719 lines | [TEXT/MPS ] |
- {[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n+]}
- { UDrawShapes.p}
- { Copyright © 1986-1990 by Apple Computer, Inc. All rights reserved.}
-
- { **** Still to do on this sample: ****
-
- Scroll selection into view when doing, undoing, or redoing commands
- (as in OneBox)
- }
- {[f-]}
- {
- This is a sample application illustrating numerous features of MacApp and the
- Printing building block.
-
- The application's windows show a palette at left, and a drawing area to the
- right; this is similar to MacDraw and MacPaint.
-
- In the windows, the user can draw quadrilaterals and ovals (choosing which
- from the palette) and can move already-drawn shapes around.
-
- Command-D is used to toggle the availability of a special 'More Debug' menu
- in the menu bar, both to illustrate how to have commands on command-keys that
- aren't themselves in the menu and how to insert and delete menus dynamically.
- Three special debugging commands are only available when this special menu
- is inserted.
-
- Full Clipboard support is also illustrated, including most features that any
- application would be likely to need. Shapes can be cut or pasted between
- documents, and picture-versions of shapes on the Clipboard can be pasted into
- other applications such as MacPaint.
-
- Printing and Filing are also supported. Window state is preserved in saved
- files. Filing uses both data and resource forks, to illustrate both
- techniques.
-
- All commands are undoable. Commands illustrated include commands to Draw,
- commands to move objects around within the view, and commands to change
- properties of objects.
-
- Hold the OPTION key down while drawing to constrain the drawing to be a
- square/circle rather than a general rectangle/oval while sketching. This
- constrains the object being drawn to be a square/circle whose side/diameter
- is a horizontal or vertical offset of the mouse from the anchor point,
- whichever is SMALLER. This may feel a bit strange in practice, but it does
- illustrate a feature.
- }
- {[f+]}
-
- UNIT UDrawShapes;
-
- INTERFACE
-
- USES
- { • MacApp }
- UMacApp,
-
- { • Building Blocks }
- UPrinting, UBetterFeedbackCmd, UMenu,
-
- { • Implementation Use }
- Picker, ToolUtils, Resources, Fonts;
-
- CONST
-
- { graphic menu }
-
- kShadesMenu = 5; { the resource ID of our menu }
-
- { Shades custom pulldown menu, menu drawing placement parameters }
- kShadesAcross = 3; { how many shades across }
- kShadesDown = 2; { how many shades down }
- kTotalShades = kShadesAcross * kShadesDown;
-
-
- kShadeTop = 3; { how far down to draw boxes containing
- shades}
- kShadeLeft = 3; { how far from left to begin drawing }
- kWShadeCell = 24; { Width of Cell }
- kHShadeCell = 24; { Height of Cell }
- kWCellSpace = 1; { width spacing between cells }
- kHCellSpace = 1; { height spacing between cells }
- kWShadeChoice = kShadeLeft + ((kWShadeCell + kWCellSpace) * kShadesAcross);
- kHShadeChoice = (kHShadeCell + kHCellSpace) * kShadesDown;
-
- { command numbers }
-
- cShadeBase = 1000;
- cWhite = 1000; {The five shades in the 'Shades' menu}
- cLtGray = 1001;
- cGray = 1002;
- cDkGray = 1003;
- cBlack = 1004;
- cShadeMax = 1004;
- kNoOfShades = cShadeMax - cShadeBase + 1;
-
- cPickColor = 1005; {Use Color Picker for shape's color}
-
- cNewShape = 1010; {Drawing a new shape}
- cMoveShape = 1011; {Moving one or more shapes}
-
- cCmdDTyped = 1200; {Command representing the fact that the user
- typed "Command-D"; in this app this is
- used as a signal to put up the "More
- Debug" menu, or if it is already up, to
- take it down -- thus demonstrating both
- how to handle commands not in the menu bar
- and how to put entire menus up and take
- them down dynamically}
-
- { The following three commands are only available in the 'More Debug' menu,
- which is only accessible if you type Cmd-D to insert that menu into
- the menu bar }
-
- cPasteReplacesSelection = 118; {Debugging: whether pasting into a shapeView
- should supplant any existing selection or
- not; if not, the pastee instead is
- centered in the window}
- cRecalcExtent = 119; {Debugging: performs immediate recomputation
- of view extent; if gConstrainDrags is
- FALSE, it is possible for a shape to be
- beyond the view border; the view's extent
- can be refigured on demand by using this
- command}
- cConstrainDrags = 120; {Debugging: whether shape-dragging should be
- constrained so that the entire selection
- fits within the view or not}
- cBetterFeedback = 121; {Debugging: whether to use the code which
- provides better TrackFeedback}
-
- { Resource types and Resource IDs }
-
- kDocRsrcKind = 'DSTA'; {Resource type for document state}
- kDocStateID = 1; {Resource id for document state}
-
- kShapeWindowRSRCID = 1005; {Resource id for the windows used by
- documents in the application}
- kShapeViewRSRCID = 1006; {Resource id for the shape view template,
- used when printing & using template views }
-
- kDocType = 'SF05'; {File-type for document files created by
- this application}
- kSignature = 'SS05'; {Application signature; Creator type for
- documents}
-
- kShapeClipType = 'SHAP'; {Clipboard type for my shapes}
-
- mColor = 6; {The Color menu resource id}
-
- mMoreDebug = 7; {Menu number for the 'More Debug' menu}
-
- { Miscellaneous }
-
- IDBox = 1; {ID of TBox items}
- IDCircle = 2; {ID of TCircle items}
- IDhBox = 3; {IDF of THeavyBox}
-
- kShapesInPalette = 3; {Number of shapes in the palette, in
- addition to the arrow}
-
- TYPE
-
- { Document state: stored in the Resource Fork of the document file; holds the
- following general properties of the document, necessary for rereading
- a saved document and restoring the appearance of the window (location,
- size, and scrolling) to its state when last saved }
- DocState = RECORD
- theNumberOfShapes: INTEGER;
- theWindowRect: Rect;
- theScrollPosition: VPoint;
- END;
- HDocState = ^PDocState; {Handle to DocState information}
- PDocState = ^DocState; {Pointer to DocState information}
-
- { Information about a single shape; same format used both in the data file
- and in the desk scrap }
- ShapeData = RECORD
- theId: INTEGER; {1 => rectangle; 2 => oval; etc.}
- theRect: Rect; {the shape's extent}
- theShade: INTEGER; {the shape's current shade}
- theColor: RGBColor; {the shape's current color}
- theSelected: BOOLEAN; {for saving window state; not relevant for
- clipboard}
- END;
-
- { Data types used for storing shapes in the Desk Scrap }
- ShapesOnClipboard = ^PShapesOnClipboard;
- PShapesOnClipboard = ^ShapeClipRecord;
- ShapeClipRecord = RECORD
- theNumberOfShapes: INTEGER;
- theBoundingBox: Rect;
- theShapes: ARRAY [0..1536] OF ShapeData;
- END;
-
- TShapeApplication = OBJECT (TApplication)
-
- { Initialization }
- PROCEDURE TShapeApplication.IShapeApplication;
-
- { Document creation }
- FUNCTION TShapeApplication.DoMakeDocument(itsCmdNumber: CmdNumber): TDocument;
- OVERRIDE;
-
- { Commands }
- {$IFC qDebug}
- FUNCTION TShapeApplication.DoCommandKey(ch: CHAR;
- VAR info: EventInfo): TCommand; OVERRIDE;
- FUNCTION TShapeApplication.DoMenuCommand(aCmdNumber: CmdNumber): TCommand; OVERRIDE;
- PROCEDURE TShapeApplication.DoSetupMenus; OVERRIDE;
- {$ENDC}
-
- FUNCTION TShapeApplication.MakeViewForAlienClipboard: TView; OVERRIDE;
- { Handle data found left in the Clipboard by forces outside the application }
-
- { Debugging }
- {$IFC qDebug}
- PROCEDURE TShapeApplication.IdentifySoftware; OVERRIDE;
- {$ENDC}
-
- END;
-
- {$IFC qHasForward}
- TShape = OBJECT; FORWARD;
- TShapeView = OBJECT; FORWARD;
- TPalette = OBJECT; FORWARD;
- TShapeReplaceCommand = OBJECT; FORWARD;
- {$EndC}
-
- TShapeDocument = OBJECT (TDocument)
-
- fShapeView: TShapeView;
- fPaletteView: TPalette;
- fShapeList: TList;
-
- fDocState: DocState;
- fReopening: BOOLEAN;
-
- fReplaceCommand: TShapeReplaceCommand; {Tells us what the current replace command
- is (Cut, Paste). NIL means there is no
- current replace command.}
- fFiltering: BOOLEAN; {Tells us whether shapes that are
- 'wasSelected' are not to be drawn if
- gLastCmdDone is TRUE}
-
- { Initialize and Free }
-
- PROCEDURE TShapeDocument.IShapeDocument(fileType: OSType);
- PROCEDURE TShapeDocument.Free; OVERRIDE;
- PROCEDURE TShapeDocument.FreeData; OVERRIDE;
-
- { Adding/deleting shapes }
-
- PROCEDURE TShapeDocument.AddShape(shape: TShape);
- PROCEDURE TShapeDocument.DeleteShape(shape: TShape);
-
- { Enumeration of shapes }
-
- PROCEDURE TShapeDocument.EachShapeDo(PROCEDURE
- DoThis(shape: TShape));
- { Iterate through the list of shapes }
-
- PROCEDURE TShapeDocument.EachPotentialShapeDo(PROCEDURE
- DoThis(shape: TShape));
- { Iterate through all the shapes in the document plus any
- 'pastee' shapes which may have been added by a not-yet-committed PASTE. }
-
- PROCEDURE TShapeDocument.EachVirtualShapeDo(PROCEDURE
- DoThis(shape: TShape));
- { Iterate through only those shapes that appear to be present at the moment
- to the USER, given the UNDO/REDO status of the last command.
- Thus it iterates through some but possibly not all of the the shapes in the
- document, and possibly also through not-yet-in-the-document pastees. }
-
- FUNCTION TShapeDocument.FirstSelectedShapeThat(FUNCTION
- TestSelectedShape(aShape: TShape):
- BOOLEAN): TShape;
-
- PROCEDURE TShapeDocument.SurveyShapes(selecteesOnly: BOOLEAN;
- VAR numberOfShapes: INTEGER;
- VAR combinedExtent: Rect);
-
- { Overrides of basic TDocument methods }
-
- PROCEDURE TShapeDocument.DoMakeViews(forPrinting: BOOLEAN); OVERRIDE;
- PROCEDURE TShapeDocument.DoNeedDiskSpace(VAR dataForkBytes,
- rsrcForkBytes: LONGINT); OVERRIDE;
-
- PROCEDURE TShapeDocument.DoRead(aRefNum: INTEGER; rsrcExists,
- forPrinting: BOOLEAN); OVERRIDE;
- PROCEDURE TShapeDocument.DoWrite(aRefNum: INTEGER; makingCopy: BOOLEAN); OVERRIDE;
-
- { Inspecting }
- PROCEDURE TShapeDocument.Fields(PROCEDURE
- DoToField(fieldName: Str255; fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
-
- END;
-
- TPalette = OBJECT (TView)
-
- fCurrShape: INTEGER; {currently selected shape, or 0 for the
- arrow}
-
- PROCEDURE TPalette.IPalette(itsDocument: TDocument);
-
- {$IFC qTemplateViews}
- PROCEDURE TPalette.IRes(itsDocument: TDocument;
- itsSuperview: TView;
- VAR itsParams: Ptr); OVERRIDE;
- {$ENDC}
-
- PROCEDURE TPalette.DoHighlightSelection(fromHL, toHL: HLState); OVERRIDE;
-
- FUNCTION TPalette.DoMouseCommand(VAR theMouse: Point; VAR info: EventInfo;
- VAR hysteresis: Point): TCommand; OVERRIDE;
-
- FUNCTION TPalette.DoSetCursor(localPoint: Point;
- cursorRgn: RgnHandle): BOOLEAN; OVERRIDE;
-
- PROCEDURE TPalette.Draw(area: Rect); OVERRIDE;
-
- { Inspecting }
-
- PROCEDURE TPalette.Fields(PROCEDURE
- DoToField(fieldName: Str255; fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
-
- END;
-
- TShapeView = OBJECT (TView)
-
- fDragging: BOOLEAN; {tells us whether the mouse is dragging}
- fPalette: TPalette; {corresponding palette}
-
- fClickPt: Point; {on PASTE, this is where the top-left point
- of the clipboard boxes go}
- fShapeDocument: TShapeDocument; {The associated document which owns the
- shapes}
- fScroller: TScroller; {corresponding scroller}
-
- { Initialization }
- PROCEDURE TShapeView.IShapeView(itsDocument: TShapeDocument; itsPalette: TPalette;
- forClipboard: BOOLEAN);
- { Initialize the view, associating it with the stated document
- and palette objects. Make it a view to be seen in the
- Clipboard only if 'forClipboard' is TRUE }
-
- {$IFC qTemplateViews}
- PROCEDURE TShapeView.IRes(itsDocument: TDocument;
- itsSuperview: TView;
- VAR itsParams: Ptr); OVERRIDE;
- {$ENDC}
-
- { Size determination }
- PROCEDURE TShapeView.CalcMinSize(VAR minSize: VPoint); OVERRIDE;
-
- { Menu commands }
- FUNCTION TShapeView.DoMenuCommand(aCmdNumber: CmdNumber): TCommand; OVERRIDE;
- { Handle the reshading and recoloring commands }
-
- PROCEDURE TShapeView.DoSetupMenus; OVERRIDE;
- { Arm the menu items handled by DoMenuCommand }
-
- { Mouse commands }
- FUNCTION TShapeView.DoMouseCommand(VAR theMouse: Point; VAR info: EventInfo;
- VAR hysteresis: Point): TCommand; OVERRIDE;
-
- { Screen display }
- PROCEDURE TShapeView.DoHighlightSelection(fromHL, toHL: HLState); OVERRIDE;
- FUNCTION TShapeView.DoSetCursor(localPoint: Point;
- cursorRgn: RgnHandle): BOOLEAN; OVERRIDE;
- PROCEDURE TShapeView.Draw(area: Rect); OVERRIDE;
- PROCEDURE TShapeView.InvalShape(aShape: TShape);
-
- { State transition }
-
- PROCEDURE TShapeView.Deselect;
- PROCEDURE TShapeView.RestoreSelection;
- PROCEDURE TShapeView.SaveSelection(andInval: BOOLEAN);
-
- { Methods only relevant for a shapeView installed in the Clipboard }
-
- FUNCTION TShapeView.ContainsClipType(aType: ResType): BOOLEAN; OVERRIDE;
- PROCEDURE TShapeView.WriteToDeskScrap; OVERRIDE;
-
- { Inspecting }
-
- PROCEDURE TShapeView.Fields(PROCEDURE
- DoToField(fieldName: Str255; fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
-
- END;
-
- TShape = OBJECT (TObject)
- fID: INTEGER;
- fExtentRect: Rect; {size of object}
- fShade: INTEGER; {shade of object}
- fOldShade: INTEGER; {with the reshade command the Undo/Redo need
- to know the old shade}
-
- fColor: RGBColor; {color of object}
- fOldColor: RGBColor; {with the recolor command the Undo/Redo need
- to know the old color}
-
- fIsSelected: BOOLEAN; {is this shape selected?}
- fWasSelected: BOOLEAN; {old selection status, set when the last
- command was performed}
-
- { Initialization }
-
- PROCEDURE TShape.Initialize; OVERRIDE;
- { Put the object into a known state from which it may be safely FREEd.
- (and hopefully a usable state) }
-
- PROCEDURE TShape.IShape(itsExtent: Rect; itsID: INTEGER);
- { Initialize a shape procedurally }
-
- { Screen display }
-
- PROCEDURE TShape.Draw;
- PROCEDURE TShape.DrawOutline;
-
- PROCEDURE TShape.EachHandleDo(PROCEDURE
- DoThis(handle: Rect; handVHS: VHSelect;
- handTopOrLeft: BOOLEAN));
-
- PROCEDURE TShape.Highlight(fromHL, toHL: HLState);
-
- { Filing }
-
- FUNCTION TShape.ID: INTEGER;
- { Used so that a filed shape can identify what kind of shape object
- is to be launched to represent it in memory }
-
- PROCEDURE TShape.ReadFrom(aRefNum: INTEGER);
- { Read the shape from input file }
-
- PROCEDURE TShape.WriteTo(aRefNum: INTEGER);
- { Write data characterizing the shape onto the Save-file }
-
- { Inspecting }
-
- PROCEDURE TShape.Fields(PROCEDURE DoToField(fieldName: Str255; fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
-
- END;
-
- TBox = OBJECT (TShape)
-
- { Initialization }
-
- PROCEDURE TBox.IBox(itsExtent: Rect; itsID: INTEGER);
-
- { Other methods }
-
- PROCEDURE TBox.Draw; OVERRIDE;
- PROCEDURE TBox.DrawOutline; OVERRIDE;
- END;
-
- THeavyBox = OBJECT (TBox) { like a box except uses up 4K bytes }
- fFiller: ARRAY [0..2048] OF INTEGER;
-
- PROCEDURE THeavyBox.IHeavyBox(itsExtent: Rect; itsID: INTEGER);
-
- PROCEDURE THeavyBox.Draw; OVERRIDE;
- END;
-
- TCircle = OBJECT (TShape)
-
- PROCEDURE TCircle.ICircle(itsExtent: Rect; itsID: INTEGER);
-
- PROCEDURE TCircle.Draw; OVERRIDE;
- PROCEDURE TCircle.DrawOutline; OVERRIDE;
- END;
-
- TShapeCommand = OBJECT (TBetterFeedbackCmd)
- { This is a common ancestor for all commands operating on one or more shapes}
-
- fShapeView: TShapeView;
- fShapeDocument: TShapeDocument;
-
- PROCEDURE TShapeCommand.IShapeCommand(itsCmdNumber: CmdNumber;
- itsShapeView: TShapeView;
- betterFeedbackDesired: BOOLEAN);
-
- { Inspecting }
-
- PROCEDURE TShapeCommand.Fields(PROCEDURE
- DoToField(fieldName: Str255; fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
-
- END;
-
- TShapeSelector = OBJECT (TShapeCommand)
- { This command demonstrates the use of a command object that
- is not saved and that does not commit the last command.
- The same effect could have been achieved by selecting the
- shapes in the TrackMouse method.}
-
- fBounds: Rect;
- fShiftKey: BOOLEAN;
-
- PROCEDURE TShapeSelector.IShapeSelector(itsCmdNumber: CmdNumber;
- itsShapeView: TShapeView);
-
- PROCEDURE TShapeSelector.DoIt; OVERRIDE;
-
- PROCEDURE TShapeSelector.TrackFeedback(anchorPoint, nextPoint: VPoint; turnItOn,
- mouseDidMove: BOOLEAN); OVERRIDE;
-
- FUNCTION TShapeSelector.TrackMouse(aTrackPhase: TrackPhase; VAR anchorPoint,
- previousPoint, nextPoint: VPoint;
- mouseDidMove: BOOLEAN): TCommand; OVERRIDE;
-
- { Inspecting }
-
- PROCEDURE TShapeSelector.Fields(PROCEDURE
- DoToField(fieldName: Str255; fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
-
- END;
-
- TShapeDragger = OBJECT (TShapeCommand)
-
- fBounds: Rect; {Union of fExtentRect of all shapes being
- dragged, before the move}
- fDeltaH: INTEGER;
- fDeltaV: INTEGER;
-
- { Initialization }
-
- PROCEDURE TShapeDragger.IShapeDragger(aShapeView: TShapeView);
-
- { Command performing }
-
- PROCEDURE TShapeDragger.DoIt; OVERRIDE;
- PROCEDURE TShapeDragger.UndoIt; OVERRIDE;
- PROCEDURE TShapeDragger.RedoIt; OVERRIDE;
-
- { Utility routine }
-
- PROCEDURE TShapeDragger.MoveBy(deltaH, deltaV: INTEGER);
-
- { Mouse Tracking }
-
- PROCEDURE TShapeDragger.TrackConstrain(anchorPoint, previousPoint: VPoint;
- VAR nextPoint: VPoint); OVERRIDE;
- { Only if gConstrainDrags is TRUE is a shapeDragger marked as
- constraining the mouse, so be sure to make gConstrainsDrags TRUE
- before mousing down on something you want to drag under constraint.
- You manipulate the gConstrainsDrags flag through a toggle in the
- 'More Debug' menu, which you get displayed by hitting Command-D }
-
- PROCEDURE TShapeDragger.TrackFeedback(anchorPoint, nextPoint: VPoint; turnItOn,
- mouseDidMove: BOOLEAN); OVERRIDE;
- FUNCTION TShapeDragger.TrackMouse(aTrackPhase: TrackPhase; VAR anchorPoint,
- previousPoint, nextPoint: VPoint;
- mouseDidMove: BOOLEAN): TCommand; OVERRIDE;
-
- { Inspecting }
-
- PROCEDURE TShapeDragger.Fields(PROCEDURE
- DoToField(fieldName: Str255; fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
-
- END;
-
- TReshadeCmd = OBJECT (TShapeCommand)
- { Note that the set of shapes affected by the reshade request is
- defined by the fWasSelected fields of the shapes themselves }
-
- fShade: INTEGER;
-
- { Command execution }
-
- PROCEDURE TReshadeCmd.IReshadeCmd(itsCmdNumber: INTEGER; itsShapeView: TShapeView);
- PROCEDURE TReshadeCmd.DoIt; OVERRIDE;
- PROCEDURE TReshadeCmd.RedoIt; OVERRIDE;
- PROCEDURE TReshadeCmd.UndoIt; OVERRIDE;
-
- END;
-
- TRecolorCmd = OBJECT (TShapeCommand)
- { Note that the set of shapes affected by the reshade request is
- defined by the fWasSelected fields of the shapes themselves }
-
- fColor: RGBColor;
-
- PROCEDURE TRecolorCmd.IRecolorCmd(itsColor: RGBColor; itsShapeView: TShapeView);
- PROCEDURE TRecolorCmd.DoIt; OVERRIDE;
- PROCEDURE TRecolorCmd.RedoIt; OVERRIDE;
- PROCEDURE TRecolorCmd.UndoIt; OVERRIDE;
-
- END;
-
- TShapeReplaceCommand = OBJECT (TShapeCommand)
- { This is a common ancestor for all commands that can add or delete shapes }
-
- PROCEDURE TShapeReplaceCommand.Commit; OVERRIDE;
- PROCEDURE TShapeReplaceCommand.EachNewShapeDo(PROCEDURE
- DoThis(shape: TShape));
- FUNCTION TShapeReplaceCommand.FirstShapeThat(FUNCTION
- TestShape(aShape: TShape): BOOLEAN):
- TShape;
- PROCEDURE TShapeReplaceCommand.RedoIt; OVERRIDE;
- PROCEDURE TShapeReplaceCommand.UndoIt; OVERRIDE;
- END;
-
- TShapeSketcher = OBJECT (TShapeReplaceCommand)
-
- fShape: TShape; {the shape sketched by the user}
-
- PROCEDURE TShapeSketcher.IShapeSketcher(aShapeView: TShapeView; protoShape: TShape;
- constrain: BOOLEAN);
- PROCEDURE TShapeSketcher.Free; OVERRIDE;
-
- PROCEDURE TShapeSketcher.EachNewShapeDo(PROCEDURE
- DoThis(shape: TShape)); OVERRIDE;
- FUNCTION TShapeSketcher.FirstShapeThat(FUNCTION
- TestShape(aShape: TShape): BOOLEAN): TShape;
- OVERRIDE;
-
- { Command performing }
- PROCEDURE TShapeSketcher.DoIt; OVERRIDE;
- PROCEDURE TShapeSketcher.RedoIt; OVERRIDE;
- PROCEDURE TShapeSketcher.UndoIt; OVERRIDE;
-
- PROCEDURE TShapeSketcher.Commit; OVERRIDE;
-
- { Mouse tracking }
- PROCEDURE TShapeSketcher.TrackConstrain(anchorPoint, previousPoint: VPoint;
- VAR nextPoint: VPoint); OVERRIDE;
- PROCEDURE TShapeSketcher.TrackFeedback(anchorPoint, nextPoint: VPoint; turnItOn,
- mouseDidMove: BOOLEAN); OVERRIDE;
- FUNCTION TShapeSketcher.TrackMouse(aTrackPhase: TrackPhase; VAR anchorPoint,
- previousPoint, nextPoint: VPoint;
- mouseDidMove: BOOLEAN): TCommand; OVERRIDE;
-
- { Inspecting }
-
- PROCEDURE TShapeSketcher.Fields(PROCEDURE
- DoToField(fieldName: Str255; fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
-
- END;
-
- TShapeCutCopyCommand = OBJECT (TShapeReplaceCommand)
-
- PROCEDURE TShapeCutCopyCommand.IShapeCutCopyCommand(itsCmdNumber: CmdNumber;
- itsShapeView: TShapeView);
- PROCEDURE TShapeCutCopyCommand.DoIt; OVERRIDE;
- PROCEDURE TShapeCutCopyCommand.RedoIt; OVERRIDE;
-
- END;
-
- TShapeClearCommand = OBJECT (TShapeReplaceCommand)
-
- PROCEDURE TShapeClearCommand.IShapeClearCommand(itsShapeView: TShapeView);
-
- PROCEDURE TShapeClearCommand.DoIt; OVERRIDE;
- PROCEDURE TShapeClearCommand.RedoIt; OVERRIDE;
-
- END;
-
- TShapePasteCommand = OBJECT (TShapeReplaceCommand)
-
- fPasteList: TList;
-
- PROCEDURE TShapePasteCommand.IShapePasteCommand(itsShapeView: TShapeView);
-
- PROCEDURE TShapePasteCommand.Free; OVERRIDE;
-
- PROCEDURE TShapePasteCommand.EachNewShapeDo(PROCEDURE
- DoThis(shape: TShape)); OVERRIDE;
- FUNCTION TShapePasteCommand.FirstShapeThat(FUNCTION
- TestShape(aShape: TShape): BOOLEAN):
- TShape; OVERRIDE;
-
- PROCEDURE TShapePasteCommand.Commit; OVERRIDE;
- PROCEDURE TShapePasteCommand.DoIt; OVERRIDE;
- PROCEDURE TShapePasteCommand.UndoIt; OVERRIDE;
- PROCEDURE TShapePasteCommand.RedoIt; OVERRIDE;
-
- END;
-
- { This is a simple menu example, it has many rough edges and can be greatly
- improved. Most custom menus you will create are regular (ie boxes across and
- down).
-
- My original concept was to provide for irregularly spaced and placed boxes
- with custom labels as well as a way to handle white space (see the sixth item in
- this menu). The IShade method could be changed to create each rectangle by
- hand should your prgram need to. FindItem returns a negative command
- associated with each rectangle, thus the addition of the instance variables
- fChoiceArray and fShadeCommands. The other approach (and most common) would
- be to have a method that calculates the item number from the mouse down
- position.
-
- }
- TShadeMenu = OBJECT (TMenu)
-
- fShadeCommands: ARRAY [1..kTotalShades] OF INTEGER;
- { array of menu commands we can select }
-
- fChoiceArray: ARRAY [1..kTotalShades] OF Rect;
- { the rectangle in the menu where we can choose }
-
- PROCEDURE TShadeMenu.IShadeMenu;
- PROCEDURE TShadeMenu.Draw(area: Rect); OVERRIDE;
- FUNCTION TShadeMenu.FindItem(hitPt: Point): INTEGER; OVERRIDE;
- PROCEDURE TShadeMenu.Highlight(whichItem: INTEGER; turnItOn: BOOLEAN); OVERRIDE;
-
- END;
-
- IMPLEMENTATION
-
- {$I UDrawShapes.inc1.p}
-
- END.
-